export default {
  data() {
    return {
      // 发布状态
      PUBLISH_STATUS_WAITING: 0,
      PUBLISH_STATUS_CANCEL: 1,
      PUBLISH_STATUS_FINISH: 2,

      // 构建状态
      DEPLOY_STATUS_NONE: 0,
      DEPLOY_STATUS_RUNNING: 1,
      DEPLOY_STATUS_FAILED: 2,
      DEPLOY_STATUS_SUCCESS: 3,
      DEPLOY_STATUS_CANCEL: 4,

      //  步骤
      STAGE_CONFIG: 0,
      STAGE_IMAGE_BUILD: 1,
      STAGE_IMAGE_BUILD_CHECK: 2,
      STAGE_DEPLOY: 3,
      STAGE_DEPLOY_CHECK: 4,

      // 运行状态
      RUNNING_STATUS_ALIVE: 1,
      RUNNING_STATUS_DEATH: 0,
      RUNNING_STATUS_UNKNOWN: 2,

      // 发布方式
      GRAY_TYPE_GRAY: '1',
      GRAY_TYPE_ALL: '0',

      // 变动常量
      COMMON_CHANGED: '1',
      COMMON_NO_CHANGED: '0',

      // 发布流程节点
      FLOW_DRAFT: 0,
      FLOW_MNG_CHECK: 1,
      FLOW_TEST: 2,
      FLOW_RC_DP: 3,
      FLOW_RC_TESTER_CONFIRM: 4,
      FLOW_RC_DEVELOPER_CONFIRM: 5,
      FLOW_PROD_DP: 6,
      FLOW_PROD_TESTER_CONFIRM: 7,
      FLOW_PROD_DEVELOPER_CONFIRM: 8,
      FLOW_FINISH: 9,

      // 发布流程状态
      FLOW_STATUS_DRAFT: 0,
      FLOW_STATUS_PROCESS: 1,
      FLOW_STATUS_FINISH: 2,
      FLOW_STATUS_REJECT: 3,
      FLOW_STATUS_DISCARD: 4,

      // 角色枚举
      ROLE_TESTER_ID: 4,
      ROLE_MANAGER_ID: 5,
      ROLE_DEPLOYER_ID: 6,

      HAS_TESTER: '1',
      NO_TESTER: '0',

      // 审批操作
      APPROVED: 1,
      REJECT: 2,
      Forward: 4,

      // 发布部署状态
      PUBLISH_DEPLOYSTATUS_RUNNING: 0,
      PUBLISH_DEPLOYSTATUS_ROLLBACK: 1,
      PUBLISH_DEPLOYSTATUS_SUCCESS: 2,
      PUBLISH_DEPLOYSTATUS_FAILED: 3
    }
  },

  methods: {
    finishStatus(deployStatus, stage) {
      if (deployStatus === undefined || stage === undefined) {
        return '未部署'
      } else if (deployStatus === this.DEPLOY_STATUS_FAILED) {
        return '部署失败'
      } else if (deployStatus === this.DEPLOY_STATUS_SUCCESS && stage === this.STAGE_DEPLOY_CHECK) {
        return '部署完成'
      } else if (deployStatus === this.DEPLOY_STATUS_NONE && stage === this.STAGE_CONFIG) {
        return '未部署'
      } else if (deployStatus === this.DEPLOY_STATUS_CANCEL) {
        return '部署取消'
      }
      return '部署中'
    },

    processStatus(deployStatus) {
      if (deployStatus === this.DEPLOY_STATUS_NONE) {
        return 'wait'
      } else if (deployStatus === this.DEPLOY_STATUS_RUNNING) {
        return 'process'
      } else if (deployStatus === this.DEPLOY_STATUS_FAILED) {
        return 'error'
      } else if (deployStatus === this.DEPLOY_STATUS_SUCCESS) {
        return 'success'
      }

      return 'wait'
    }
  }
}
